package com.gupao.pattern.proxy.dbroute.db;

/**
 *
 */
public class DynamicDataSourceEntity {

    private final static String DEFAULT_SOURCE=null;

    private static final ThreadLocal<String> local = new ThreadLocal<String>();

    private DynamicDataSourceEntity() {

    }

    public static String get() {
        return local.get();
    }

    public static void restore(){
        local.set(DEFAULT_SOURCE);
    }

    //DB_2018、DB_2019
    public static void set(String sourceName) {
        local.set(sourceName);
    }

    public static void set(int year) {
        local.set("DB_" + year);
    }
}
